package top.malaoshi.ctrl;

import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.malaoshi.model.Result;

@RestController
//@CrossOrigin(allowCredentials = "true")
public class RegCtrl {
    @RequestMapping("/doReg")
    public Result reg(String phone, String password, String password2){
        Result res = new Result();
        if(phone==null||"".equals(phone)){
            res.setCode(1);
            res.setMsg("手机号不能为空，请输入手机号！");
            return res;
        }
        if(password==null||"".equals(password)){
            res.setCode(2);
            res.setMsg("密码不能为空，请输入密码！");
            return res;
        }
        if(password2==null||"".equals(password2)){
            res.setCode(2);
            res.setMsg("确认密码不能为空，请输入确认密码！");
            return res;
        }
        if(!password.equals(password2)){
            res.setCode(3);
            res.setMsg("密码不一致，请重新输入！");
            return res;
        }

        res.setCode(0);
        res.setMsg("注册成功！");
        return res;
    }
}